// // 获取同类作品推荐
// export function getRecommendBook(id) {
// 	return Vue.http.get(`/book/${id}/recommend`)
// }
// // 
// export function getReviewsList(id, count) {
// 	return Vue.http.get(`/post/review/best-by-book?book=${id}&&sort=comment-count&start=0&limit=${count}`)
// }
// // 获取小说源
// export function getMixinSource(id) {
// 	return Vue.http.get('/btoc?view=summary&book=' + id)
// }

// // 获取章节信息
// export function getChapters(id) {
// 	return Vue.http.get(`/btoc/${id}?view=chapters&channel=mweb`)
// }

// // 获取小说章节内容
// export function getChapterText(id) {
// 	return axios.get(`/chapterapi/chapter/${id}/cv=1495097622174`)
// }
const baseAPIUrl = "http://api.zhuishushenqi.com";
const getApiData = {
	// 获取书单
	getBookList: () => {
		return new Promise((resolve, reject) => {
			uni.request({
				url: baseAPIUrl + '/book-list',
				success: (res) => {
					resolve(res.data)
				},
				fail: (err) => {
					reject(err)
				}
			})
		})
	},
	// 获取排行榜数据
	getBookListDetail: (id) => {
		return new Promise((resolve, reject) => {
			uni.request({
				url: baseAPIUrl + '/book-list/' + id,
				success: (res) => {
					resolve(res.data)
				},
				fail: (err) => {
					reject(err)
				}
			})
		})
	},
	// 获取书本信息
	getBookInfo: (id) => {
		return new Promise((resolve, reject) => {
			uni.request({
				url: baseAPIUrl + '/book/' + id,
				success: (res) => {
					resolve(res.data)
				},
				fail: (err) => {
					reject(err)
				}
			})
		})
	},
	// 获取同类作品推荐
	getRecommendBook: (id) => {
		return new Promise((resolve, reject) => {
			uni.request({
				url: baseAPIUrl + `/book/${id}/recommend`,
				success: (res) => {
					resolve(res.data)
				},
				fail: (err) => {
					reject(err)
				}
			})
		})
	},
	// 获取小说评论列表
	getReviewsList: (id, count) => {
		return new Promise((resolve, reject) => {
			uni.request({
				url: baseAPIUrl + `/post/review/best-by-book?book=${id}&&sort=comment-count&start=0&limit=${count}`,
				success: (res) => {
					resolve(res.data)
				},
				fail: (err) => {
					reject(err)
				}
			})
		})
	},
	// 获取小说源
	getMixinSource: (id) => {
		return new Promise((resolve, reject) => {
			uni.request({
				url: baseAPIUrl + '/btoc?view=summary&book=' + id,
				success: (res) => {
					resolve(res.data)
				},
				fail: (err) => {
					reject(err)
				}
			})
		})
	},
	// 获取章节信息
	getChapters: (id) => {
		return new Promise((resolve, reject) => {
			uni.request({
				url: baseAPIUrl + `/btoc/${id}?view=chapters&channel=mweb`,
				success: (res) => {
					resolve(res.data)
				},
				fail: (err) => {
					reject(err)
				}
			})
		})
	},
	// 获取小说章节内容
	getChapterText: (id) => {
		return new Promise((resolve, reject) => {
			uni.request({
				url: baseAPIUrl + `/chapterapi/chapter/${id}/cv=1495097622174`,
				success: (res) => {
					resolve(res.data)
				},
				fail: (err) => {
					reject(err)
				}
			})
		})
	},
};

export default getApiData